package follow.juc.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author tu zy
 * @Date 2020/11/30 17:03
 * @Version 1.0
 */
public class Case_1 implements Runnable{
    public static void main(String[] args) {
        ExecutorService executorService = new ThreadPoolExecutor(3, 10, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>(64), (Runnable runnable) -> {
            Thread thread = new Thread(runnable);
            thread.setName("backup-task-thread-");
            return thread;
        });

        executorService.submit(()-> executeBackup());
    }


    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
    }


    public static void executeBackup(){
        System.out.println(Thread.currentThread().getName());
    }
}
